<?php

  //////////////////////////////////////////////////////////////////
  // OrbitFAQ                                                     //
  // ---------                                                    //
  //                                                              //
  // Orbit FAQ was solely written and developed by Orbit Services //
  // http://www.orbitservices.net                                 //
  //                                                              //
  // Access the Forum here:                                       //
  // http://forums.orbitservices.net/index.php?c=4                //
  //                                                              //
  // OrbitFAQ utilises the following opensource projects/classes; //
  //  + Fckeditor - http://www.fckeditor.net                      //
  //  + Smarty Template Engine - http://smarty.php.net            //
  //  + Swift Email Class - http://www.swiftmailer.org/           //
  //  + OWASP PHP Filter Project - http://www.owasp.org           //
  //  + MySQL Search Class by Stephen Bartholomew                 //
  //                                                              //
  //////////////////////////////////////////////////////////////////

  $smarty->assign("OrbitFAQTitle","Banlist Management");

  // Standard Functions
  function ReOrderFAQ($faq)
    {

      require('../incs/config.inc.php');
      require('../incs/db.inc.php');

      $new_order = '0';

      $query_faq_order = "SELECT * from orbitfaq ORDER BY faq_order ASC";
      $result_faq_order = $faqsql_query ($query_faq_order)OR DIE( "$sql_query_error $query_faq_order");

      while ($row_faq_order = $faqsql_fetch_array ($result_faq_order)){
        $faq_id_order = $row_faq_order[0];

        $new_order = $new_order+10;

        $query_update_order = "UPDATE `orbitfaq` SET `faq_order` = '$new_order' WHERE `id` = '$faq_id_order';";
        $result_update_order = $faqsql_query ($query_update_order)OR DIE( "$sql_query_error $query_update_order");

      }

    }

  if($action != '')
    {
      $smarty_template_file = "$AdminFullPath/skins/$AdminSkin/mod_". $mod ."_". $action .".tpl";

      if($action == 'create')
        {

          if($posted == 'yes')
            {

              $posted_type = strip_tags($_POST['posted_type']);
              $posted_detail = strip_tags($_POST['posted_detail']);

              if(!$posted_type){ $error .= " &raquo; You did not enter a <u>Type</u><br />"; }
              if(!$posted_detail){ $error .= " &raquo; You did not enter a <u>Detail</u><br />"; }

              if(!$error)
                {

                  $query_add = "INSERT INTO `orbitfaq_banlist` (
                      `ban_type`,
                      `detail`
                    )VALUES(
                      '$posted_type',
                      '$posted_detail'
                    );

                  ";

                  $result_add = $faqsql_query ($query_add)OR DIE( "$sql_query_error $query_add");

                  clearSmartyCompiled($SmartyCompileDir, $ClearSmartyCompiled);

                  $message = "New Banned Item Was Successfully Created!";
                  header("Location: index.php?mod=$mod&message=$message");

                  exit;

                }
              else
                {

                  $smarty->assign("posted_detail","$posted_detail");
                  $smarty->assign("posted_type","$posted_type");
                  $smarty->assign("Errors","$error");

                }

            }

      } // End Create

    elseif($action == 'delete')
      {
        if($bl != '')
          {

          if($posted == 'yes')
            {

              $posted_confirmation = sanitize_paranoid_string($_POST['posted_confirmation']);
              $posted_faq = sanitize_paranoid_string($_POST['posted_faq']);

              $smarty->assign("posted_faq","$faq_id");

              if($posted_confirmation == '0'){ $error .= " &raquo; You did not select an appropriate <u>Confirmation</u><br />"; }

              if(!$error)
                {

                  // Delete Our Banned Item
                  $query_delete = "DELETE FROM `orbitfaq_banlist` WHERE `id` = '$bl';";
                  $result_delete = $faqsql_query ($query_delete)OR DIE( "$sql_query_error $query_delete");

                  clearSmartyCompiled($SmartyCompileDir, $ClearSmartyCompiled);

                  $message = "Banned Item was Successfully Deleted!";
                  header("Location: index.php?mod=$mod&message=$message");

                  exit;

                }

            }

                $query_bl = "SELECT * from orbitfaq_banlist ORDER BY ban_type DESC";
                $result_bl = $faqsql_query ($query_bl)OR DIE( "$sql_query_error $query_bl");

                while ($row_bl = $faqsql_fetch_array ($result_bl)){
                  $bl_id = $row_bl[0];
                  $bl_type = $row_bl[1];
                  $bl_detail = $row_bl[2];

                // Assign our smarty details
                $smarty->assign("Errors","$error");
                $smarty->assign("posted_id","$bl_id");
                $smarty->assign("posted_title","$bl_detail");

              }

          }
        else
          {
            clearSmartyCompiled($SmartyCompileDir, $ClearSmartyCompiled);

            $message = "You Did Not Enter a Valid Id!";
            header("Location: index.php?mod=$mod&message=$message");
          }
      } // End Delete

    }
  else
    {
      $smarty_template_file = "$AdminFullPath/skins/$AdminSkin/mod_". $mod .".tpl";

      $query_bl = "SELECT * from orbitfaq_banlist ORDER BY ban_type DESC";
      $result_bl = $faqsql_query ($query_bl)OR DIE( "$sql_query_error $query_bl");

      while ($row_bl = $faqsql_fetch_array ($result_bl)){
        $bl_id = $row_bl[0];
        $bl_type = $row_bl[1];
        $bl_detail = $row_bl[2];

        if($bl_row == '1')
          {
            $bl_row = '0';
          }
        else
          {
            $bl_row = '1';
          }


         // Build Smarty Content Array
         $smarty_bl_array[] = array(
            "bl_id" => "$bl_id",
            "bl_type" => "$bl_type",
            "bl_detail" => "$bl_detail",
            "bl_row" => "$bl_row"
          );

      }

      // Send our Smarty Data
      $smarty->assign('BLListing',$smarty_bl_array);
    }
?>